#define _CRT_SECURE_NO_WARNINGS 1 
#include<stdio.h>
int get_month_of_days(int y, int m)
{
	int days[] = { 0,31,28,31,30,31,30,31,31,30,31,30,31 };
	int day = days[m];
	if ((y % 4 == 0 && y % 100 != 0) || y % 400 == 0)
	{
		if (2 == m)
			day += 1;
	}
	return day;
}
int main()
{
	int y = 0;
	int m = 0;
	scanf("%d %d", &y, &m);
	int ret = get_month_of_days(y, m);
	printf("%d", ret);
	return 0;
}